// powerup.cpp
#include "powerup.h"
#include <QTimer>
#include <QDateTime>
PowerUp::PowerUp(Type type, QGraphicsItem* parent)
    : QGraphicsPixmapItem(parent), m_type(type)
{
    QString imagePath;
    switch(type) {
    case Shield: imagePath = ":/魔法棒.png"; break;
    case Magnet: imagePath = ":/磁铁.png"; break;
    case Hover: imagePath = ":/竹蜻蜓.png"; break;
    }
    setPixmap(QPixmap(imagePath));

    // 添加浮动动画
    QTimer* floatTimer = new QTimer(this);
    connect(floatTimer, &QTimer::timeout, [this]() {
        setY(y() + 5 * sin(QDateTime::currentMSecsSinceEpoch() / 200.0));
    });
    floatTimer->start(50);
}
